#include "GVersion.h"

namespace GEngine
{

	GVersion::GVersion(GUInt16 VerMajor, GUInt16 VerMinor, GUInt16 VerRevision)
	{
		Minor = VerMinor;
		Major = VerMajor;
		Revision = VerRevision;

		char VersionStr[32] = {0};
		sprintf_s(VersionStr, 16, "Version: %d.%d.%d", Major, Minor, Revision);

		VersionString = VersionStr;
	}

	GVersion::~GVersion()
	{
	
	}

	GUInt32 GVersion::GetMajor() const
	{
		return Major;
	}

	GUInt32 GVersion::GetMinor() const
	{
		return Minor;
	}

	GUInt32 GVersion::GetRevision() const
	{
		return Revision;
	}

	const char* GVersion::GetString() const
	{
		return VersionString.c_str();
	}

	const GVersion& GVersion::operator  = (const GVersion& Other)
	{
		Major = Other.Major;
		Minor = Other.Minor;
		Revision = Other.Revision;
		VersionString = Other.VersionString;

		return *this;
	}

	// Does not consider revision number since, it should not cause compatibility issues
	bool GVersion::operator >= (const GVersion& Other) const
	{
		GUInt32 Combined = ((GUInt32)Major << 16) | Minor;
		GUInt32 OtherCombined = ((GUInt32)Other.Major << 16) | Other.Minor;

		return Combined >= OtherCombined;
	}

	// Does not consider revision number since, it should not cause compatibility issues
	bool GVersion::operator <= (const GVersion& Other) const
	{
		GUInt32 Combined = ((GUInt32)Major << 16) | Minor;
		GUInt32 OtherCombined = ((GUInt32)Other.Major << 16) | Other.Minor;

		return Combined <= OtherCombined;
	}

	GVersion GVersion::GetEngineVersion()
	{
		return GVersion(G_ENGINE_VERSION_MAJOR, 
						G_ENGINE_VERSION_MINOR, 
						G_ENGINE_VERSION_REVISION);
	}

}